#include<bits/stdc++.h>
#define int long long 
using namespace std;

int ksm(int a,int b,int p){
	int t=1;
	while(b){
		if(b&1)t=t*a%p;
		b>>=1;
		a=a*a%p;
	}
	return t%p;
}

signed main(){
	int a,b,p;
	cin>>a>>b>>p;
	cout<<ksm(a,b,p)<<endl;
	 
	return 0;
}
